from django import forms
from django.core import validators
from django.forms import ModelForm
from django.forms import forms
from toast.models import *
from datetime import datetime
from django.contrib.admin import widgets

class MeetingForm(ModelForm):
	def __init__(self,  *args, **kwargs):
		super(MeetingForm, self).__init__(*args, **kwargs)

		self.fields['name'].required=True
		self.fields['start_datetime'].required=True
		self.fields['end_datetime'].required=True
		self.fields['start_datetime'].widget=widgets.AdminSplitDateTime()
		self.fields['end_datetime'].widget=widgets.AdminSplitDateTime()

	class Meta:
		model=Meeting

class MemberForm(ModelForm):
	def __init__(self, *args, **kwargs):
		super(MemberForm, self).__init__(*args, **kwargs)

		self.fields['first_name'].required=True
		self.fields['last_name'].required=True
		self.fields['email'].required=True
		self.fields['phone'].required=True

	class Meta:
		model=Member

class AddressForm(ModelForm):
	def __init__(self, *args, **kwargs):
		super(AddressForm, self).__init__(*args, **kwargs)

		self.fields['name'].required=True
		self.fields['street_address'].required=True
		self.fields['city'].required=True
		self.fields['state'].required=True
		self.fields['postalcode'].required=True

	class Meta:
		model=Address

class SoundForm(ModelForm):
	def __init__(self, *args, **kwargs):
		super(SoundForm, self).__init__(*args, **kwargs)

		self.fields['name'].required=True

	class Meta:
		model=Sound

class RoleForm(ModelForm):
	def __init__(self, *args, **kwargs):
		super(RoleForm, self).__init__(*args, **kwargs)

		self.fields['name'].required=True

	class Meta:
		model=Role

class ParticipationTypeForm(ModelForm):
	def __init__(self, *args, **kwargs):
		super(ParticipationTypeForm, self).__init__(*args, **kwargs)

		self.fields['name'].required=True
		self.fields['description'].required=False

	class Meta:
		model=ParticipationType

class AttendanceForm(ModelForm):
	def __init__(self, *args, **kwargs):
		super(AttendanceForm, self).__init__(*args, **kwargs)

	class Meta:
		model=Attendance

class ParticipationForm(ModelForm):
	def __init__(self, *args, **kwargs):
		super(ParticipationForm, self).__init__(*args, **kwargs)

		self.fields['name'].required=False
		self.fields['attendance'].required=True
		self.fields['participation_type'].required=True

	class Meta:
		model=Participation

class TrackSoundForm(ModelForm):
	def __init__(self, *args, **kwargs):
		super(TrackSoundForm, self).__init__(*args, **kwargs)

		self.fields['sound'].required=True
		self.fields['participant'].required=True
		self.fields['count'].required=True

	class Meta:
		model=TrackSound

class StateForm(ModelForm):
	def __init__(self, *args, **kwargs):
		super(StateForm, self).__init__(*args, **kwargs)

		self.fields['short_name'].required=True
		self.fields['long_name'].required=True

	class Meta:
		model=State